FROM golang:1.16 as builder

ENV GO111MODULE=on
ENV GOPROXY=https://goproxy.cn,direct

WORKDIR /go/src/httpserver

COPY ./go.mod /go/src/httpserver/go.mod
COPY ./go.sum /go/src/httpserver/go.sum
RUN go mod download

COPY ./ /go/src/httpserver

RUN CGO_ENABLED=0 GOOS=linux GOARCH=amd64 go build -o httpserver

FROM alpine:latest

WORKDIR /data/bin/httpserver
COPY --from=builder /go/src/httpserver/httpserver /data/bin/httpserver
COPY --from=builder /go/src/httpserver/config.yaml /data/bin/httpserver/config.yaml
RUN chmod +x /data/bin/httpserver
ENV TZ=Asia/Shanghai

CMD ["./httpserver"]